#ifndef	_PARSER_H_
#define	_PARSER_H_

#include "types.h"
#include "Match.h"
#include <vector>
#include <sys/types.h>
#include "Globals.h"

using namespace std;

class Parser
{
  private:
	int fd;
	size_t fromPos;
	off_t fileSize;
///	vector<char *> titleLines;

	// An helping struct that will keep a starting position and the length so far of a sub-match
	struct SubMatch
	{
		uint inPos;
		uint refPos;
		uint length;
		uint trashChars;	// The number of trash chars in the input chunk until the current inPos

		SubMatch(uint _inPos, uint _refPos, uint _length, uint _trashChars) : inPos(_inPos), refPos(_refPos), length(_length), trashChars(_trashChars)
		{ }
	};

  public:

	/* C'tor -
	 *	Receives a file-descriptor of an open input file, a position to begin reading from (the rest will be taken from Globals)
	 */
	Parser(int fd, size_t fromPos, off_t fileSize);

	~Parser();

	/*
	 * Parses the chunk of the given size and returns a vector of all Matches that were found in that chunk, the names of input sequences that were found during the parsing and returns (in the return value) the first line string.
	 */
	char *parseChunk(uint chunkSize, vector<Name *> &names, size_t &badCharsSLN, size_t &badMM);

};


#endif	/* _PARSER_H_ */

